{extend name='public/layout' /}

{block name="assign"}
{if isset($info)}
{assign name="page_title" value="编辑广告" /}
{else/}
{assign name="page_title" value="新增广告" /}
{/if}
{/block}

{block name='body'}
<div class="layui-card">
	<div class="layui-card-body">
		<form method="post" action="{:url()}" class="layui-form layui-form-edit">
			<input type="hidden" name="id" value="{$info.id|default=0}">
			<input type="hidden" name="http_referer" value="{$Request.server.HTTP_REFERER|default=''}"/>

			<div class="layui-form-item">
				<label class="layui-form-label" for="ad_id">所属广告位</label>
				<div class="layui-input-inline">
					<select id="ad_id" name="ad_id" lay-verify="required">
						{volist name='ad_list' id='vo'}
						<option value="{$vo.id}">{$vo.title|raw}</option>
						{/volist}
					</select>
					<div class="layui-form-mid"></div>
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label" for="title">标题</label>
				<div class="layui-input-block">
					<input type="text" id="title" name="title" value="{$info.title|default=''}" placeholder="请输入标题" class="layui-input" lay-verify="required" autocomplete="on"/>
					<div class="layui-form-mid"></div>
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">封面<i class="required"></i></label>
				<div class="layui-input-inline">
					<div data-img-uploader="{name:'cover'}" data-path="{$info.cover|default=''}"></div>
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label" for="click_type">点击类型</label>
				<div class="layui-input-inline">
					<select id="click_type" name="click_type" lay-verify="required">
						<option value="0">打开图片</option>
						<option value="1">打开地址</option>
					</select>
					<div class="layui-form-mid"></div>
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">原图<i class="required"></i></label>
				<div class="layui-input-inline">
					<div data-img-uploader="{name:'origin_cover'}" data-path="{$info.origin_cover|default=''}"></div>
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label" for="url">链接<i class="required"></i></label>
				<div class="layui-input-block">
					<input type="text" id="url" name="url" value="{$info.url|default=''}" placeholder="请输入链接" class="layui-input" lay-verify="required"/>
					<div class="layui-form-mid">小程序时请填写页面路径</div>
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label" for="status">状态</label>
				<div class="layui-input-inline">
					<input type="hidden" name="status" value="0"/>
					<input type="checkbox" id="status" name="status" value="1" lay-filter="status" lay-skin="switch" lay-text="启用|禁用"/>
					<div class="layui-form-mid"></div>
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label" for="sort">排序</label>
				<div class="layui-input-inline">
					<input type="number" id="sort" name="sort" value="{$info.sort|default=0}" class="layui-input" placeholder="请输入排序" lay-verify="required"/>
					<div class="layui-form-mid"></div>
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label" for="begin_time">显示时间</label>
				<div class="layui-input-inline">
					<input type="text" id="begin_time" name="begin_time" value="{$info.begin_time|default=''}" class="layui-input" placeholder="请输入开始时间"
							lay-verify="required" data-datetime="{'type':'datetime'}" readonly/>
				</div>
				<div class="layui-input-inline">
					<input type="text" id="end_time" name="end_time" value="{$info.end_time|default=''}" class="layui-input" placeholder="请输入结束时间"
							lay-verify="required" data-datetime="{'type':'datetime'}" readonly/>
				</div>
			</div>

			<div class="layui-form-item">
				<div class="layui-input-block">
					<button type="submit" class="layui-btn layui-btn-danger" data-ajax-post="{target:'.layui-form'}">
						<i class="fa fa-save"></i> 保存
					</button>
					<a href="javascript:history.back();" class="layui-btn layui-btn-primary">取消 </a>
				</div>
			</div>
		</form>
	</div>
</div>
{/block}

{block name='scriptVar'}
xin.setValue('#category_id',{$info.pid|default=''});
xin.setChecked('#status',{$info.status|default='1'});
{/block}
